package com.xiaoxing.zhinenghuacangku_jining.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xiaoxing.zhinenghuacangku_jining.R;
import com.xiaoxing.zhinenghuacangku_jining.mvp.ui.entity.JiNing_DianBiaoChuKuRenWuLieBiao;

import java.util.List;

//import me.jessyan.armscomponent.commonres.utils.GlideUtil;


public class JiNing_DianBiaoChuKuRenWuLieBiaoAdapter extends BaseQuickAdapter<JiNing_DianBiaoChuKuRenWuLieBiao, BaseViewHolder> {

    private Context mContext;
    private IJiNing_DianBiaoChuKuRenWuLieBiaoAdapter mIJiNing_dianBiaoChuKuRenWuLieBiaoAdapter;

    public JiNing_DianBiaoChuKuRenWuLieBiaoAdapter(Context context, @Nullable List<JiNing_DianBiaoChuKuRenWuLieBiao> data, IJiNing_DianBiaoChuKuRenWuLieBiaoAdapter iJiNing_dianBiaoChuKuRenWuLieBiaoAdapter) {
        super(R.layout.zhi_neng_cang_ku_ji_ning_item_dian_biao_chu_ku_ren_wu_lie_biao, data);
        this.mContext = context;
        this.mIJiNing_dianBiaoChuKuRenWuLieBiaoAdapter = iJiNing_dianBiaoChuKuRenWuLieBiaoAdapter;
    }

    @Override
    protected void convert(BaseViewHolder helper, JiNing_DianBiaoChuKuRenWuLieBiao item) {
        //GlideUtil.loadImage(mContext,item.getImg(),helper.getView(R.id.img_head));
        helper.setText(R.id.tv_name, "备注： " + item.getRemark());
        helper.setText(R.id.tv_spname, "需退回数量： " + item.getReturnnum());
        helper.setText(R.id.tv_num, "数量： " + item.getNum());
        helper.setText(R.id.tv_taskStatus, "任务状态： " + item.getTaskstatus());
        Button btn_que_ren_tui_hui = helper.getView(R.id.btn_que_ren_tui_hui);
        Button btn_que_ren_chu_ku = helper.getView(R.id.btn_que_ren_chu_ku);

        if (item.getTaskstatus().equals("退回剩余")) {
            btn_que_ren_tui_hui.setVisibility(View.VISIBLE);
            btn_que_ren_chu_ku.setVisibility(View.GONE);

            helper.setOnClickListener(R.id.btn_que_ren_tui_hui, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mIJiNing_dianBiaoChuKuRenWuLieBiaoAdapter.queRenTuiHui(item);
                }
            });

        } else if (item.getTaskstatus().equals("确认出库")) {
            btn_que_ren_tui_hui.setVisibility(View.GONE);
            btn_que_ren_chu_ku.setVisibility(View.VISIBLE);

            helper.setOnClickListener(R.id.btn_que_ren_chu_ku, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mIJiNing_dianBiaoChuKuRenWuLieBiaoAdapter.queRenChuKu(item);
                }
            });

        } else {
            btn_que_ren_tui_hui.setVisibility(View.GONE);
            btn_que_ren_chu_ku.setVisibility(View.GONE);
        }

    }

    public interface IJiNing_DianBiaoChuKuRenWuLieBiaoAdapter {

        void queRenTuiHui(JiNing_DianBiaoChuKuRenWuLieBiao item);

        void queRenChuKu(JiNing_DianBiaoChuKuRenWuLieBiao item);


    }

}
